<?php
class mortgage_calculator 
{
	private $assessed_value;
	private $anual_interest_rate;
	private $down_payment;
	private $financed_price;
	private $property_tax_rate;
	private $sales_price;
	
	private $errors;
	
	function __construct($anual_interest_rate, $down_payment, $financed_price, $sales_price, $assessed_value, $property_tax_rate)
	{
		$this->anual_interest_rate 	= $this->floater ( $anual_interest_rate ) ;
		$this->assessed_value 		= $this->clean_numbers ( $assessed_value );
		$this->down_payment 		= $this->clean_numbers ( $down_payment );
		$this->financed_price 		= $this->clean_numbers ( $financed_price );
		$this->property_tax_rate  	= $this->floater ( $property_tax_rate );
		$this->sales_price 			= $this->clean_numbers ( $sales_price );
		
	}

	public function get_down_payment()
	{
		
	}
	
	public function get_financed_amount()
	{
		
	}
	
	public function get_annual_interest_rate()
	{
		
	}
	
	public function get_monthly_interest_rate()
	{
		
	}
	
	public function get_monthly_payment()
	{
		
	}
	
	public function get_property_tax($type = 'annual')
	{
		
	}

	public function requires_PMI()
	{
		
	}
	
	public function get_monthly_payment($principle = TRUE, $interest = TRUE, $tax = TRUE, $insurance = TRUE, $other = TRUE)
	{
		
	}
	
	private function get_interest_factor
	
	private function validate_inputs()
	{
		$error = array();
		
		if ( !$this->anual_interest_rate ) {
			$error[] = 'anual_interest_rate';
		}
		
		if ( !$this->assessed_value ) {
			$error[] = 'assessed_value';
		}
		
		if ( !$this->down_payment ) {
			$error[] = 'down_payment';
		}
		
		if ( !$this->financed_price ) {
			$error[] = 'financed_price';
		}
		
		if ( !$this->sales_price ) {
			$error[] = 'sales_price';
		}
		
		if ( !$this->property_tax_rate ) {
			$error[] = 'property_tax_rate';
		}
		
		if ( count ( $error ) ) {
			$this->errors['inputs'] = $error;
			return FALSE;	
		}
		
		return TRUE;
	}

	private function clean_numbers ( $input ) 
	{
		
		$input =  preg_replace('/[^0-9.]/', '', $input);
		
		return ( is_int($input ) ) ? $input : FALSE;
	}
	
	private function floater ( $input )
	{
		$input = $this->clean_numbers($input);
		
		if ( !is_int ( $input ) ) {
			return FALSE;
		}
		
		if ( is_float ($input) && $input < 1 ) {
			return $input;
		}
		
		if ( is_float ($input) && $input > 1 ) {
			return $input / 100;	
		}
		
		if ( is_int ( $input ) && $input > 1) {
			$this->floater($input / 100);
		}
		
		return FALSE;
	}

	private function dollar_dollar_bills_yall ( $input ) 
	{
		return '$' . number_format ( $input, "2", ".", "," );
	}
}